package com.qc.controller;

import com.qc.dto.Result;
import com.qc.enity.Type;
import com.qc.exception.ResultCodeEnum;
import com.qc.service.ITypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 菜的种类相关操作控制层
 */
@RestController
@RequestMapping("type")
@CrossOrigin
public class TypeController {
    @Autowired
    private ITypeService typeService;

    @GetMapping("{typeId}")
    public Result<List<Type>> selectType(@PathVariable Integer typeId) {
        //判断查询的typeId是否为空
        if (typeId == null || typeId < 0) {
            return Result.error(ResultCodeEnum.TYPE_NULL.getCode(), ResultCodeEnum.TYPE_NULL.getMsg());
        }
        return Result.successResult(typeService.getByRevertId(typeId));
    }
}
